<template>
  <el-dialog
    :visible.sync="visible"
    title="审核"
    :close-on-click-modal="false"
    :close-on-press-escape="false"
    top="70px"
  >
    <div class="dialogInner">
      <el-form
        :model="check"
        ref="check"
        :label-width="$i18n.locale === 'en-US' ? '150px' : '150px'"
      >
        <el-row>
          <!-- <h3>基本信息</h3> -->
          <el-col :span="12">
            <el-form-item label="商户名称" prop="">
              {{ dataForm.merchantName || "--" }}
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="商户类型" prop="merchantType">
              {{ $getDictLabel("MerchantType", dataForm.merchantType) }}
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="提现金额(元)" prop="">
              {{ dataForm.amount || "--" }}
            </el-form-item>
          </el-col>
          <h3>审核意见</h3>
          <el-col :span="24">
            <el-form-item
              label="审核结果"
              label-width="120px"
              prop="checkStatus"
              :rules="{
                required: true,
                message: this.$t('validate.required'),
                trigger: 'blur',
              }"
            >
              <el-select
                v-model="check.checkStatus"
                placeholder="请选择审核结果"
                clearable
              >
                <el-option label="通过" value="1"></el-option>
                <el-option label="不通过" value="2"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="审核反馈" label-width="120px" prop="">
              <el-input
                v-model="check.checkFeedback"
                type="textarea"
                rows="2"
                autocomplete="off"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <template slot="footer">
      <el-button type="primary" @click="checkData(dataForm.id)">确定</el-button>
    </template>
  </el-dialog>
</template>

<script>
import debounce from "lodash/debounce";
export default {
  data() {
    return {
      visible: false,
      dataForm: {
        id: "",
      },
      check: {
        checkFeedback: "",
        checkStatus: "",
        id: "",
      },
    };
  },
  filters: {
    delService(val) {
      let str = "";
      if (val != "null" && val) {
        let arr = JSON.parse(val);
        arr.forEach((item, i) => {
          str += item.provideService;
        });
      }
      return str;
    },
  },
  methods: {
    confirmCheck() {
      this.$http
        .post("/order/ismerchantwithdrawalcheckinfo/audit",this.check)
        .then((res) => {
          if (res.data.code != 0) {
            return this.$message.error(res.data.msg);
          }
          this.$message({
            message: "操作成功",
            type: "success",
            duration: 500,
            onClose: () => {
              this.visible = false;
              this.$emit("refreshDataList");
            },
          });
        });
    },
    init() {
      this.visible = true;
      this.check.checkFeedback = "";
      this.check.checkStatus = "";
      this.$nextTick(() => {
        if (this.dataForm.id) {
          this.getInfo();
        }
      });
    },

    // 获取信息
    getInfo() {
      this.$http
        .get("/order/ismerchantwithdrawalcheckinfo/" + this.dataForm.id)
        .then(({ data: res }) => {
          if (res.code !== 0) {
            return this.$message.error(res.msg);
          }
          this.dataForm = {
            ...this.dataForm,
            ...res.data,
          };
        })
        .catch(() => {
          
        });
    },
    // 表单提交
    checkData: debounce(
      function () {
        this.$refs["check"].validate((valid) => {
          if (!valid) {
            return false;
          }
          this.check.id = this.dataForm.id;
          this.confirmCheck();
        });
      },
      1000,
      {
        leading: true,
        trailing: false,
      }
    ),
  },
};
</script>

<style scoped lang="scss">
.avatar-uploader {
  .el-upload {
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;

    .el-upload:hover {
      border-color: #409eff;
    }
  }

  .avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 158px;
    height: 158px;
    line-height: 158px;
    text-align: center;
  }

  .avatar {
    width: 158px;
    height: 158px;
    display: block;
  }
}

h3 {
  padding: 30px 0 15px;
  width: 94%;
  margin: 0 auto 30px;
  border-bottom: 1px solid #ddd;
  color: #303133;
  font-size: 20px;
  overflow: hidden;
}
</style>
